package com.soup.lab.spring.aop;

import com.soup.lab.spring.aop.component.DoServiceImpl;
import com.soup.lab.spring.aop.component.IntroductionAdd;
import com.soup.lab.spring.aop.component.IntroductionAddImpl;
import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DelegatingIntroductionInterceptor;

public class CreateProxyTestCase {

    @Test
    public void test() {
        ProxyFactory proxyFactory = new ProxyFactory();
        proxyFactory.addAdvice(new DelegatingIntroductionInterceptor(new IntroductionAddImpl(100)));
        proxyFactory.setTarget(new DoServiceImpl());
        Object proxy = proxyFactory.getProxy();
        ((IntroductionAdd)proxy).add();
    }


}
